package com.activity.shop;

import android.os.Bundle;

import com.activity.AttendanceActivity;
import com.activity.App;
import com.activity.adapter.ApplicationAdapter;
import com.activity.bean.ApplicationBean;
import com.donkingliang.groupedadapter.adapter.GroupedRecyclerViewAdapter;
import com.donkingliang.groupedadapter.holder.BaseViewHolder;
import com.activity.bean.UserBean;
import com.donkingliang.groupedadapter.layoutmanger.GroupedGridLayoutManager;
import com.example.apple.ddhr_new.R;
import com.example.apple.ddhr_new.utils.ActivityUtil;
import com.example.lzbase.BaseViewModelActivity;

import java.util.List;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;

public class ShopMangerActivity extends BaseViewModelActivity {


    @BindView(R.id.recycle_view)
    RecyclerView recycleView;
    private ApplicationAdapter applicationAdapter;

    @Override
    protected int titleText() {
        return R.string.app_name;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_shop_manger;
    }

    @Override
    protected void created(@Nullable Bundle savedInstanceState) {
        super.created(savedInstanceState);

        applicationAdapter=new ApplicationAdapter(this);
        List<UserBean.UserstoreinfoBean> stores = App.getInstance().getAccount().getUserstoreinfo();
        if(stores!=null&&stores.size()>0){
            applicationAdapter.userstoreinfoBean = stores.get(0);
            setTitleText(stores.get(0).getStorename());
            App.getInstance().userstoreinfoBean = stores.get(0);

        }else {
            setTitleText("");

        }
        loadData();
        recycleView.setAdapter(applicationAdapter);
        //直接使用GroupGridLayoutManager实现子项的Grid效果
        GroupedGridLayoutManager gridLayoutManager = new GroupedGridLayoutManager(this, 4, applicationAdapter);
        recycleView.setLayoutManager(gridLayoutManager);

        applicationAdapter.setOnChildClickListener(new GroupedRecyclerViewAdapter.OnChildClickListener() {
            @Override
            public void onChildClick(GroupedRecyclerViewAdapter adapter, BaseViewHolder holder, int groupPosition, int childPosition) {
                if(groupPosition==1){

                    if(childPosition==0){
                        ActivityUtil.startActivity(ShopMangerActivity.this,AttendanceActivity.class);
                    }
                }
            }
        });
    }

    private void loadData() {

        ApplicationAdapter adapter = applicationAdapter;
        
        ApplicationBean A = new ApplicationBean(R.string.changyong_gongneng);
        adapter.getData().add(A);
        ApplicationBean.ApplicationItemBean Aitem1 =new ApplicationBean.ApplicationItemBean(R.string.kaoqin_guanli,R.drawable.shop_kaoqin);
        A.data.add(Aitem1);
        ApplicationBean.ApplicationItemBean Aitem2 =new ApplicationBean.ApplicationItemBean(R.string.vip_guanli,R.drawable.shop_vip);
        A.data.add(Aitem2);
        ApplicationBean.ApplicationItemBean Aitem3 =new ApplicationBean.ApplicationItemBean(R.string.shangpin_guanli,R.drawable.shop_shangpin);
        A.data.add(Aitem3);
        ApplicationBean.ApplicationItemBean Aitem4 =new ApplicationBean.ApplicationItemBean(R.string.dianpu_dingdan,R.drawable.shop_dingdan);
        A.data.add(Aitem4);


        ApplicationBean f = new ApplicationBean(R.string.richang_guanli);
        adapter.getData().add(f);
        ApplicationBean.ApplicationItemBean fitem1 =new ApplicationBean.ApplicationItemBean(R.string.kaoqin_guanli,R.drawable.shop_kaoqin);
        f.data.add(fitem1);
        ApplicationBean.ApplicationItemBean fitem2 =new ApplicationBean.ApplicationItemBean(R.string.shoukuan_guanli,R.drawable.shop_shoukuan);
        f.data.add(fitem2);
        ApplicationBean.ApplicationItemBean fitem3 =new ApplicationBean.ApplicationItemBean(R.string.yuyue_shezhi,R.drawable.shop_yuyue);
        f.data.add(fitem3);
        ApplicationBean.ApplicationItemBean fitem4 =new ApplicationBean.ApplicationItemBean(R.string.dianpu_dingdan,R.drawable.shop_dingdan);
        f.data.add(fitem4);


        ApplicationBean B = new ApplicationBean(R.string.yeji_guanli);
        adapter.getData().add(B);
        ApplicationBean.ApplicationItemBean Bitem1 =new ApplicationBean.ApplicationItemBean(R.string.dianpu_yeji,R.drawable.shop_yeji);
        B.data.add(Bitem1);
        ApplicationBean.ApplicationItemBean Bitem2 =new ApplicationBean.ApplicationItemBean(R.string.geren_yeji,R.drawable.shop_geren_yeji);
        B.data.add(Bitem2);
        ApplicationBean.ApplicationItemBean Bitem3 =new ApplicationBean.ApplicationItemBean(R.string.yeji_fenpei,R.drawable.shop_yeji_fenpei);
        B.data.add(Bitem3);


        ApplicationBean C = new ApplicationBean(R.string.yinxiao_guanli);
        adapter.getData().add(C);

        ApplicationBean.ApplicationItemBean Citem1 =new ApplicationBean.ApplicationItemBean(R.string.tehui_huodong,R.drawable.shop_tehui);
        C.data.add(Citem1);

        ApplicationBean.ApplicationItemBean Citem2 =new ApplicationBean.ApplicationItemBean(R.string.youhuiquan_guanli,R.drawable.shop_youhuiquan);
        C.data.add(Citem2);



        ApplicationBean D = new ApplicationBean(R.string.dianpu_jichusheshi);
        adapter.getData().add(D);

        ApplicationBean.ApplicationItemBean Ditem1 =new ApplicationBean.ApplicationItemBean(R.string.bianji_dianpu,R.drawable.shop_bianji);
        D.data.add(Ditem1);
        ApplicationBean.ApplicationItemBean Ditem2 =new ApplicationBean.ApplicationItemBean(R.string.shangpin_guanli,R.drawable.shop_shangpin);
        D.data.add(Ditem2);
        ApplicationBean.ApplicationItemBean Ditem3 =new ApplicationBean.ApplicationItemBean(R.string.shouquan_guanli,R.drawable.shop_shouquan);
        D.data.add(Ditem3);
        ApplicationBean.ApplicationItemBean Ditem4 =new ApplicationBean.ApplicationItemBean(R.string.jishi_guanli,R.drawable.shop_jishi);
        D.data.add(Ditem4);
        ApplicationBean.ApplicationItemBean Ditem5 =new ApplicationBean.ApplicationItemBean(R.string.vip_guanli,R.drawable.shop_vip);
        D.data.add(Ditem5);
        ApplicationBean.ApplicationItemBean Ditem6 =new ApplicationBean.ApplicationItemBean(R.string.jicika_guanli,R.drawable.shop_jicika);
        D.data.add(Ditem6);
        ApplicationBean.ApplicationItemBean Ditem7 =new ApplicationBean.ApplicationItemBean(R.string.tianjia_dianpu,R.drawable.shop_tianjia);
        D.data.add(Ditem7);




    }
}
